##                     ##
#   Auth.log Monitor    #
#     Author:Plaix      #
##                     ##

import commands
from time import strftime


class monAuth():
    def __init__(self):
        self.name="Auth log Monitor"
        self.result=""
        self.type="LOGIN"
    def check(self):
        global result
        global type
        self.cmd="tail -12 /var/log/auth.log | grep \"Accepted\" | cut -d \" \" -f1-4,9-12"
        current=[]
        temp=commands.getoutput(self.cmd)
        current=temp.split('\n')
        if(current[-1]!=self.result):
            self.result=current[-1]
            return 1
        else:
            return 0
